<template>
  <el-row>
    <el-col :span="24">
      <el-carousel :interval="3000" arrow="always" height="30vw" type="card">
        <el-carousel-item>
          <h3><img :src="`/imags/${imgs[0]}`" alt="" /></h3>
        </el-carousel-item>
        <el-carousel-item>
          <h3><img :src="`/imags/${imgs[1]}`" alt="" /></h3>
        </el-carousel-item>
        <el-carousel-item>
          <h3><img :src="`/imags/${imgs[2]}`" alt="" /></h3>
        </el-carousel-item>
        <el-carousel-item>
          <h3><img :src="`/imags/${imgs[3]}`" alt="" /></h3>
        </el-carousel-item>
      </el-carousel>
    </el-col>
  </el-row>
</template>
<script>
export default {
  data() {
    return {
      imgs: [],
    };
  },
  mounted() {
    //获取数据
    this.$axios.get("/").then((result) => {
      //打印数据
      console.log(result.data);
      //变量保存数据
      let res = result.data.data;
      //循环判断
      for (var i in res) {
        if (i < 4) {
          this.imgs.push(res[i].img);
        }
      }
      console.log(this.imgs);
    });
  },
};
</script>
<style>
img {
  width: 100%;
  height: auto;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 20px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>






